using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Common;
using IGlobalist.Cms.Bll;
using IGlobalist.Cms.Model;

namespace IGlobalist.Cms.Admin.Control
{
    public partial class ContentListTitle : AdminBaseUserControl
    {
        public event EventHandler SelectedContentChanged;
        public event EventHandler OnloadBindData;
        #region Properties
            public string SelectedValue
            {
                get { return Convert.ToString(ViewState["ContentID"]); }
                set { ViewState["ContentID"] = value; }
            }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {         
        }
        public IList<IContent> DataSource
        {
            set { ViewState["_contentList"] = value; }
        }
        public override void DataBind()
        {
            base.DataBind();
            BindData();
        }
        public void BindData()
        { 
            IList<IContent> contentList = (IList<IContent>)ViewState["_contentList"];
            if(contentList.Count>0)
            {
                IContent content = contentList[0];
                gvcContentTitle.DataSource = contentList;
                gvcContentTitle.DataBind();
            }
        }
        protected void tvContentList_SelectedNodeChanged(object sender, EventArgs e)
        {
            if (SelectedContentChanged != null)
            {
                SelectedContentChanged(this, e);
            }
        }

        protected void lbTitle_Click(object sender, EventArgs e)
        {
            LinkButton lb = (LinkButton)sender;
            long Id = Convert.ToInt64(lb.CommandArgument);
            SelectedValue = Id.ToString();
            if (SelectedContentChanged != null)
            {
                SelectedContentChanged(this, e);
            }
        }
    }
}